<template>
  <section class="hui-box" :class="{ 'hui-box--shadow': shadow }">
    <div class="hui-box__header" v-if="header || $slots.header">
      <slot name="header">{{ header }}</slot>
    </div>
    <div class="hui-box__main" v-if="main || $slots.default">
      <slot>{{ main }}</slot>
    </div>
    <div class="hui-box__footer" v-if="footer || $slots.footer">
      <slot name="footer">{{ footer }}</slot>
    </div>
  </section>
</template>

<script>
/**
   * z-box
   * @module common/h-box
   * @desc 表单盒子, 把表单放进来, 显得非常整齐
   *
   * @param { string, slot } header - 标题内容
   * @param { string, slot } main - 主内容
   * @param { string, slot } footer - 底部内容
   * @param { boolean } shadow - 有没有阴影
   */
export default {
  name: 'h-box',
  componentName: 'h-box',
  props: {
    header: String,
    main: String,
    footer: String,
    shadow: Boolean
  }
}
</script>

<style lang="less">
  @import '../h-theme/_variable';

  @hui-box-color: tint(@--background-color-base, 40%);
  @hui-box-padding: 20px;

  .hui-box {
    display: block;
    border: 4px solid @hui-box-color;
  }

  .hui-box--shadow {
    box-shadow: @--box-shadow-base;
  }

  .hui-box + .hui-box {
    margin-top: @hui-box-padding;
  }

  .hui-box__header {
    padding: 16px @hui-box-padding;
    background-color: @hui-box-color;
    font-size: @--font-size-base;
    vertical-align: middle;
  }

  .hui-box__main {
    padding: @hui-box-padding;
  }

  .hui-box__footer {
    padding: 16px @hui-box-padding;
    vertical-align: middle;
    background-color: @hui-box-color;
  }
</style>
